package com.sky.lightleafpicturepavilionserver.domain;

import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;

import java.io.Serial;
import java.io.Serializable;
import java.time.LocalDateTime;

import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;

/**
 * 用户壁纸下载历史表
 * @TableName user_wallpaper_download
 */
@TableName(value ="user_wallpaper_download")
@Data
@AllArgsConstructor
@NoArgsConstructor
@Builder
public class UserWallpaperDownload implements Serializable {
    /**
     * 下载记录ID，主键
     */
    @TableId(value = "id", type = IdType.AUTO)
    private Long id;

    /**
     * 用户ID
     */
    @TableField(value = "user_id")
    private Long userId;

    /**
     * 壁纸ID
     */
    @TableField(value = "wallpaper_id")
    private Long wallpaperId;

    /**
     * 消耗的能量
     */
    @TableField(value = "energy_cost")
    private Integer energyCost;

    /**
     * 下载的图片URL
     */
    @TableField(value = "download_url")
    private String downloadUrl;

    /**
     * 设备信息
     */
    @TableField(value = "device_info")
    private String deviceInfo;

    /**
     * IP地址
     */
    @TableField(value = "ip_address")
    private String ipAddress;

    /**
     * 下载时间
     */
    @TableField(value = "create_time")
    private LocalDateTime createTime;

    @Serial
    @TableField(exist = false)
    private static final long serialVersionUID = 1L;

    @Override
    public boolean equals(Object that) {
        if (this == that) {
            return true;
        }
        if (that == null) {
            return false;
        }
        if (getClass() != that.getClass()) {
            return false;
        }
        UserWallpaperDownload other = (UserWallpaperDownload) that;
        return (this.getId() == null ? other.getId() == null : this.getId().equals(other.getId()))
            && (this.getUserId() == null ? other.getUserId() == null : this.getUserId().equals(other.getUserId()))
            && (this.getWallpaperId() == null ? other.getWallpaperId() == null : this.getWallpaperId().equals(other.getWallpaperId()))
            && (this.getEnergyCost() == null ? other.getEnergyCost() == null : this.getEnergyCost().equals(other.getEnergyCost()))
            && (this.getDownloadUrl() == null ? other.getDownloadUrl() == null : this.getDownloadUrl().equals(other.getDownloadUrl()))
            && (this.getDeviceInfo() == null ? other.getDeviceInfo() == null : this.getDeviceInfo().equals(other.getDeviceInfo()))
            && (this.getIpAddress() == null ? other.getIpAddress() == null : this.getIpAddress().equals(other.getIpAddress()))
            && (this.getCreateTime() == null ? other.getCreateTime() == null : this.getCreateTime().equals(other.getCreateTime()));
    }

    @Override
    public int hashCode() {
        final int prime = 31;
        int result = 1;
        result = prime * result + ((getId() == null) ? 0 : getId().hashCode());
        result = prime * result + ((getUserId() == null) ? 0 : getUserId().hashCode());
        result = prime * result + ((getWallpaperId() == null) ? 0 : getWallpaperId().hashCode());
        result = prime * result + ((getEnergyCost() == null) ? 0 : getEnergyCost().hashCode());
        result = prime * result + ((getDownloadUrl() == null) ? 0 : getDownloadUrl().hashCode());
        result = prime * result + ((getDeviceInfo() == null) ? 0 : getDeviceInfo().hashCode());
        result = prime * result + ((getIpAddress() == null) ? 0 : getIpAddress().hashCode());
        result = prime * result + ((getCreateTime() == null) ? 0 : getCreateTime().hashCode());
        return result;
    }

    @Override
    public String toString() {
        return getClass().getSimpleName() +
                " [" +
                "Hash = " + hashCode() +
                ", id=" + id +
                ", userId=" + userId +
                ", wallpaperId=" + wallpaperId +
                ", energyCost=" + energyCost +
                ", downloadUrl=" + downloadUrl +
                ", deviceInfo=" + deviceInfo +
                ", ipAddress=" + ipAddress +
                ", createTime=" + createTime +
                ", serialVersionUID=" + serialVersionUID +
                "]";
    }
}